package com.david.cms.dao;

import org.springframework.stereotype.Repository;

import com.david.basic.dao.BaseDao;
import com.david.basic.model.Pager;
import com.david.cms.model.Member;

@Repository("memberDao")
public class MemberDao extends BaseDao<Member> implements IMemberDao {

	public void addMember(Member member) throws Exception {
		super.add(member);
	}

	public Member searchMember(int id) throws Exception {
		return (Member) super.queryObjcet("from Member where id=?", id);
	}

	public Member login(String loginName, String password) throws Exception {
		return (Member) super.queryObjcet("from Member where loginName=? and passWord=?",
				new Object[] { loginName, password });
	}

	public Pager<Member> searchMemberByPage(Pager pager) {
		return super.find("from Member");
	}

	public void deleteMember(int id) {
		// super.delete(id);
		super.updateByHql("delete from Member where id=?", id);
	}

	public Member isUse(String loginName) {
		return (Member) super.queryObjcet("from Member where loginName=?", loginName);
	}

	public void updateMember(Member member) {
		super.updateByHql("update Member set email=?,passWord=?,realName=? where id=?",
				new Object[] { member.getEmail(), member.getPassWord(), member.getRealName(),
						member.getId() });
	}

}
